import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Arrays;
import java.util.Scanner;

public class test {

    //登录
    public static User login() {
        System.out.println("请输入姓名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int choice = 0;
        do{
            System.out.println("*******1.普通用户 2.管理员用户********");
            System.out.println("请输入身份：");
            choice = scanner.nextInt();
            if(choice == 1) {
                //普通用户
                return new NormalUser(name);
            }else if(choice == 2) {
                //管理员用户
                return new AdminUser(name);
            }else {
                //重新输入
                System.out.println("输入不合法,请重新输入!!!");
            }
        }while (choice != 1 || choice != 2);

        return null;
    }

    //实现不同的操作
    public static void Opera(int choice) {

    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while(true) {
            int choice = user.menu();
            if(choice == 0) {
                break;
            }
            user.run(bookList, choice);
        }
    }



}
